<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="ID" prop="id">
        <el-input
          v-model="queryParams.id"
          placeholder="请输入ID"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="注册类型" prop="registrationType">
        <el-select v-model="queryParams.registrationType" placeholder="请选择注册类型">
          <el-option
            label="全部类型"
            value="99">
          </el-option>
          <el-option
            label="公众号注册"
            value="2">
          </el-option>
          <el-option
            label="小程序注册"
            value="3">
          </el-option>
          <el-option
            label="app注册"
            value="4">
          </el-option>
          <el-option
            label="系统注册"
            value="5">
          </el-option>
          <el-option
            label="H5注册"
            value="6">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="实名认证状态" prop="realNameAuthenticationStatus">
        <el-select v-model="queryParams.realNameAuthenticationStatus" placeholder="请选择实名认证类型">
          <el-option
            label="全部类型"
            value="99">
          </el-option>
          <el-option
            label="已认证"
            value="1">
          </el-option>
          <el-option
            label="未认证"
            value="0">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="手机号" prop="phone">
        <el-input
          v-model="queryParams.phone"
          placeholder="请输入手机号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="状态" prop="status">
        <el-select v-model="queryParams.status" placeholder="请选择状态">
          <el-option
            label="全部类型"
            value="99">
          </el-option>
          <el-option
            label="禁用"
            value="0">
          </el-option>
          <el-option
            label="正常"
            value="1">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="创建时间" prop="time">
        <el-date-picker
          v-model="queryParams.time"
          type="daterange"
          value-format="yyyy-MM-dd"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="真实姓名" prop="name">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入真实姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['personnel:courier:add']"
        >新增</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="memberList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="ID" align="center" prop="id">
        <template slot-scope="scope">
          <span @click="getCourierById(scope.row)" style="color:#6a9eff;text-decoration: underline;">{{scope.row.id}}</span>
        </template>
      </el-table-column>
      <el-table-column label="注册类型" align="center" prop="registrationType">
        <template slot-scope="scope">
          {{scope.row.registrationType==2?'公众号注册':scope.row.registrationType==3 ?'小程序注册':scope.row.registrationType==4?'APP注册':scope.row.registrationType==5?'系统注册':'H5注册'}}
        </template>
      </el-table-column>
      <el-table-column label="手机号码" align="center" prop="phone" />
      <el-table-column label="真实姓名" align="center" prop="name" />
      <el-table-column label="创建时间" align="center" prop="createTime" width="180">
        <template slot-scope="scope">
          {{scope.row.createTime}}
        </template>
      </el-table-column>
      <el-table-column label="注册IP" align="center" prop="registeredIp" />
      <el-table-column label="会员余额" align="center" prop="memberBalance">
        <template slot-scope="scope">
          {{scope.row.memberBalance.toFixed(2)}}
        </template>
      </el-table-column>
      <el-table-column label="实名认证状态" align="center" prop="realNameAuthenticationStatus">
        <template slot-scope="scope">
          {{scope.row.realNameAuthenticationStatus==0?'未认证':'已认证'}}
        </template>
      </el-table-column>
      <el-table-column label="状态" align="center" prop="status">
        <template slot-scope="scope">
          {{scope.row.status==0?'禁用':'正常'}}
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click.native.stop="resetLoginPassword(scope.row.lid)"
          >重置登录密码</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click.native.stop="resetPaymentPassword(scope.row.lid)"
          >置空支付密码</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click.native.stop="updateStatus(scope.row)"
            v-if="scope.row.status==1"
          >禁用</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            v-if="scope.row.status==0"
            @click.native.stop="updateStatus(scope.row)"
          >启用</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加快递员列表管理对话框 -->
    <el-dialog title="添加快递员" :visible.sync="openInsert">
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="区号" prop="areacode">
          <el-select v-model="form.areacode" placeholder="请选择">
          <el-option
            label="+86 中国"
            value="+86">
          </el-option>
          <el-option
            label="+63 菲律宾"
            value="+63">
          </el-option>
        </el-select>
        </el-form-item>
        <el-form-item label="快递员手机号" prop="phone">
          <el-input
            v-model="form.phone"
            placeholder="请填写手机号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="真实姓名" prop="name">
          <el-input
            v-model="form.name"
            placeholder="请填写姓名"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
         <el-form-item label="快递公司" prop="courierCompany">
        <el-select v-model="form.courierCompany" placeholder="请选择快递公司">
          <el-option
            label="小默配送"
            value="小默配送">
          </el-option>
          <el-option
            label="菲度"
            value="菲度">
          </el-option>
          <el-option
            label="Foodpanda"
            value="Foodpanda">
          </el-option>
        </el-select>
      </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 快递员信息详情对话框 -->
    <el-dialog title="快递员信息详情" :visible.sync="openPojo">
      <el-form ref="pojo" :model="pojo" label-width="80px">
        <el-avatar shape="circle" style="width: 50px;height: 50px">
          <img :src='pojo.avatar' style="width: 50px;height: 50px">
        </el-avatar>
        <el-form-item label="真实姓名" prop="name">
          {{pojo.name}}
        </el-form-item>
        <el-form-item label="手机号" prop="phone">
          {{pojo.phone}}
        </el-form-item>
        <el-form-item label="注册类型" prop="">
          {{pojo.phone}}
        </el-form-item>
        <el-form-item label="快递公司" prop="courierCompany">
          {{pojo.courierCompany}}
        </el-form-item>
        <el-form-item label="实名认证" prop="realNameAuthenticationStatus">
          {{pojo.realNameAuthenticationStatus==0?'未认证':'已认证'}}
        </el-form-item>
        <el-form-item label="会员余额" prop="memberBalance">
          {{pojo.memberBalance}}
        </el-form-item>
        <el-form-item label="会员状态" prop="memberBalance">
          {{pojo.memberBalance}}
        </el-form-item>
        <el-form-item label="登录密码" prop="loginpasswordstatus">
          {{pojo.loginpasswordstatus==0?'未设置':'已设置'}}
        </el-form-item>
        <el-form-item label="支付密码" prop="paymentpasswordstatus">
          {{pojo.paymentpasswordstatus==0?'未设置':'已设置'}}
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

https://spyx-demotest01.oss-cn-beijing.aliyuncs.com/%E5%9B%BE%E7%89%87/ff14/-A_KTovWBuvRDUZIadls49CHpk.jpg

<script>
import { listMember, getMember, delMember, addMember, updateStatus, resetLoginPassword,  resetPaymentPassword} from "@/api/personnel/courier";

export default {
  name: "Member",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      showSearch1: true,
      // 总条数
      total: 0,
      // 快递员列表管理表格数据
      memberList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      openInsert: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        id: null,
        memberType: null,
        name: null,
        phone: null,
        registrationType: '99',
        courierCompany: 'all',
        createTime: null,
        realNameAuthenticationStatus: '99',
        status: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        areacode:[
          {required:true,message:"请选择区号",trigger:'blur'}
        ],
        phone:[
          {required:true,message:"请填写手机号",trigger:'blur'}
        ],
        name:[
          {required:true,message:"请填写姓名",trigger:'blur'}
        ],
        courierCompany:[
          {required:true,message:"请选择快递公司",trigger:'blur'}
        ]
      },
      pojo:{},
      openPojo:false,
    };
  },
  created() {
    this.getList();
  },
  activated() {
    this.getList();
  },
  methods: {
    /** 查询快递员列表管理列表 */
    getList() {
      this.loading = true;
      listMember(this.queryParams).then(response => {
        this.memberList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /* 查询快递员的详细信息 */
    getCourierById(row){
      const id=row.id;
      this.$router.push({
        path: '/personnel/member-data/index/' + id
      })
    },
    // 取消按钮
    cancel() {
      this.openInsert = false;
      this.openPojo = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        memberType: null,
        name: null,
        phone: null,
        registrationType: null,
        courierCompany: null,
        createTime: null,
        registeredIp: null,
        memberBalance: null,
        realNameAuthenticationStatus: null,
        status: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      if(this.queryParams.time!=null){
        const time=this.queryParams.time;
        this.queryParams.startTime=time[0];
        this.queryParams.endTime=time[1];
      }else{
        this.queryParams.startTime=null;
        this.queryParams.endTime=null;
      }

      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.openInsert = true;
      this.title = "添加快递员列表管理";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getCourier(id).then(response => {
        this.form = response.data;
        this.openInsert = true;
        this.title = "修改快递员列表管理";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          let phone=this.form.areacode+"-"+this.form.phone;
          this.form.phone=phone;
          console.log(this.form.phone);
            addCourier(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.openInsert = false;
              this.getList();
            });
          }
      });
    },
    resetLoginPassword(lid){
      this.$confirm('您确定要重置该快递员的登录密码?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          resetLoginPassword(lid).then(response=>{
            this.getList();
            this.$message({
              type: 'success',
              message: '重置成功!'
            });
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消重置'
          });
        });
    },
    resetPaymentPassword(lid){
      this.$confirm('您确定要置空该快递员的支付密码?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          resetPaymentPassword(lid).then(response=>{
            this.getList();
            this.$message({
              type: 'success',
              message: '置空成功!'
            });
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消置空'
          });
        });
    },
    /*修改快递员状态*/
    updateStatus(row){
      if(row.status=='1'){
        this.$confirm('您确定要禁用该快递员?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          updateStatus(row).then(response=>{
            this.getList();
            this.$message({
              type: 'success',
              message: '禁用成功!'
            });
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消禁用'
          });
        });
      }else{
        this.$confirm('您确定要启用该快递员?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          updateStatus(row).then(response=>{
            this.getList();
            this.$message({
              type: 'success',
              message: '启用成功!'
            });
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消启用'
          });
        });
      }
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除快递员列表管理编号为"' + ids + '"的数据项？').then(function() {
        return delCourier(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('personnel/courier/export', {
        ...this.queryParams
      }, `courier_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
